package com.itheima.socket.tcp.demo07;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class ClientDemo07 {

    public static void main(String[] args) throws IOException {

        Socket socket = new Socket("192.168.19.34", 9797);
        OutputStream outputStream = socket.getOutputStream();
        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream));
        Scanner scanner = new Scanner(System.in);
        while (true) {
            String next = scanner.next();
            if (next.equals("886")){
                //以下3行代码必须有，要把结束语句写到通道中，服务端才能读到
                bufferedWriter.write(next);
                bufferedWriter.newLine();
                bufferedWriter.flush();
                break;
            }
            bufferedWriter.write(next);
            bufferedWriter.newLine();
            bufferedWriter.flush();
        }

    }
}
